package com.tone.ji_volunteer.globalexceptionhandler;

import com.tone.ji_volunteer.pojo.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author tone(ang)
 * version 1.0
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    public Result ex(Exception e){
        System.out.println("Exception:" + e.getMessage());
        e.printStackTrace();//打印堆栈中的异常信息
        return Result.error("对不起,操作失败,请联系管理员");
    }
}
